package com.example.demo2.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import androidx.annotation.Nullable;

import com.example.demo2.R;

public class LoginActivity extends Activity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.act_login);
        initWidget();

    }

    private void initWidget() {

        Button button = findViewById(R.id.login_btn);

        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                EditText usernameEditText = findViewById(R.id.edit_username);

                EditText passwordEditText = findViewById(R.id.edit_password);

                Intent intent = new Intent();
                intent.putExtra("username", usernameEditText.getText().toString());
                intent.putExtra("password", passwordEditText.getText().toString());

                setResult(RESULT_OK, intent);

                LoginActivity.this.finish();
            }
        });
    }

}
